package example;
import facecat.topin.core.*;
import facecat.topin.tab.FCTabPage;
import facecat.topin.xml.*;
import facecat.topin.btn.*;
import facecat.topin.swing.*;

public class RadioButtonExample extends FCUIXml
{
    /*
     * 加载Xml
     * @param fileName 文件名
     * @param view 视图名称
     */
    public void loadXml(String fileName, FCView view)
    {
        setScript(new FaceCatScript(this));
        super.loadXml(fileName, view);
        //获取第二页
        FCTabPage tabPage = getTabPage("TabPage2");
        FCRadioButton radioButton = new FCRadioButton();
        radioButton.setLocation(new FCPoint(100, 100));
        radioButton.setSize(new FCSize(100, 20));
        tabPage.addView(radioButton);
        radioButton.setText("选项");
        radioButton.setChecked(true);

        //从Xml中获取按钮
        FCRadioButton button1 = getRadioButton("RadioButton");
        FCRadioButton button2 = getRadioButton("RadioButton2");
        FCRadioButton button3 = getRadioButton("RadioButton3");

        //绑定选项改变事件
        button1.addEvent(this, FCEventID.CheckedChanged, this);
        button2.addEvent(this, FCEventID.CheckedChanged, this);
        button3.addEvent(this, FCEventID.CheckedChanged, this);
        radioButton.addEvent(this, FCEventID.CheckedChanged, this);
    }

    /*
     * 事件
     * @param eventName 事件ID
     * @param sender 发送者
     * @param invoke 引用者
     */
    public void callEvent(String eventName, Object sender, Object invoke)
    {
        FCRadioButton radioButton = (FCRadioButton)sender;
    }
}